﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace SlamDunk.CMS.DAL
{
    /// <summary>
    /// User数据访问层类（手写部分类）
    /// </summary>
    public partial class UserDal : IDAL.IUserDal
    {
        #region 01.根据用户名获取单个实体对象
        /// <summary>
        /// 根据用户名获取单个实体对象
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>单个实体对象</returns>
        public Model.User GetModel(string userName)
        {
            string sql = "SELECT * FROM Users WHERE UserName = @UserName";
            using (SqlDataReader reader = DbHelper.ExecuteReader(sql, new SqlParameter("@UserName", userName)))
            {
                if (reader.Read())
                {
                    return ToModel(reader);
                }
                else
                {
                    return null;
                }
            }
        }
        #endregion
    }
}
